/*
 * TestGenericKey.cpp
 *
 *  Created on: Oct 28, 2013
 *      Author: carlos
 */

#include "TestGenericKey.h"
#include "../../src/logical_layer/bplustree/GenericKey.h"
#include <assert.h>
#include <list>
TestGenericKey::TestGenericKey() {

}

TestGenericKey::~TestGenericKey() {
}

void TestGenericKey::run() {
	GenericKey g1(1);
	GenericKey g1prima(1);
	assert(g1 == g1prima);

	GenericKey g100(100);
	GenericKey g200(200);
	assert(g100 < g200);

	GenericKey g20(20);
	assert(g1 < g20);

	GenericKey g14(14);
	assert(g14 < g20);

	GenericKey g10(10);
	assert(g1 < g10);

	GenericKey g2(2);
	assert(g2 < g10);
	cout << "TEST GENERICKEY          OK" << endl;
	testKeys(200);
	testKeys(1000);
	testKeys(1000);
}

void TestGenericKey::testKeys(int cant) {

	GenericKey* genericsKey=new GenericKey[cant];
	for(int i=1;i<cant;i++){
		genericsKey[i]=GenericKey(i);
	}

	for(int i=1;i<cant;i++){
		GenericKey g1=genericsKey[i];
		for (int j=i+1;j<cant;j++){
			GenericKey g2=genericsKey[j];
			assert(g1<g2);
		}
	}

	delete[] genericsKey;


	cout << "TEST "<<cant<<" GENERICKEY          OK" << endl;
}
